library(readxl)
mydata <- read_xlsx("./Mobile phone.xlsx")
mydata <- as.data.frame(mydata)
mydata$Gender <- factor(mydata$Gender,
levels = c("M", "F"),
labels = c("M", "F"))
head(mydata)
## ID Mobile Gender
## 1 1 10 M
## 2 2 11 M
## 3 3 15 F
## 4 4 14 F
## 5 5 12 F
## 6 6 13 F
Description of variables:
library(ggplot2)
Male <- ggplot(mydata[mydata$Gender == "M", ], aes(x = Mobile)) +
theme_linedraw() +
geom_histogram(binwidth = 1, colour = "black", fill = "darkblue") +
ylab("Frequency") +
scale_x_continuous(breaks = seq(0, 20, 2), limits = c(-1, 21)) +
ggtitle("Male")
Female <- ggplot(mydata[mydata$Gender == "F", ], aes(x = Mobile)) +
theme_linedraw() +
geom_histogram(binwidth = 1, colour = "black", fill = "darkred") +
ylab("Frequency") +
scale_x_continuous(breaks = seq(0, 20, 2), limits = c(-1, 21)) +
ggtitle("Female")
library(ggpubr)
ggarrange(Male, Female,
ncol = 2, nrow = 1)
## Warning: Removed 2 rows containing missing values or values outside the scale
## range (`geom_bar()`).
## Removed 2 rows containing missing values or values outside the scale
## range (`geom_bar()`).
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(rstatix)
##
## Attaching package: 'rstatix'
## The following object is masked from 'package:stats':
##
## filter
mydata %>%
group_by(Gender) %>%
shapiro_test(Mobile)
## # A tibble: 2 × 4
## Gender variable statistic p
## <fct> <chr> <dbl> <dbl>
## 1 M Mobile 0.916 0.00439
## 2 F Mobile 0.977 0.326
library(psych)
##
## Attaching package: 'psych'
## The following objects are masked from 'package:ggplot2':
##
## %+%, alpha
describeBy(mydata$Mobile, mydata$Gender)
##
## Descriptive statistics by group
## group: M
## vars n mean sd median trimmed mad min max range skew
## X1 1 42 11.45 3.09 11 11.47 2.97 0 18 18 -0.74
## kurtosis se
## X1 2.81 0.48
## ----------------------------------------------------
## group: F
## vars n mean sd median trimmed mad min max range skew
## X1 1 58 12.45 2.68 12.5 12.44 2.22 7 18 11 -0.03
## kurtosis se
## X1 -0.74 0.35
wilcox.test(mydata$Mobile ~ mydata$Gender,
correct = FALSE,
exact = FALSE,
alternative = "two.sided")
##
## Wilcoxon rank sum test
##
## data: mydata$Mobile by mydata$Gender
## W = 982.5, p-value = 0.09786
## alternative hypothesis: true location shift is not equal to 0
library(ggplot2)
ggplot(mydata, aes(x = Mobile, fill = Gender)) +
geom_histogram(position = position_dodge(width = 0.5), binwidth = 1, colour = "Black") +
scale_x_continuous(breaks = seq(0, 20, 1)) +
ylab("Frequency") +
labs(fill = "Group")
ggplot(mydata, aes(x = Mobile, linetype = Gender)) +
geom_freqpoly(binwidth = 1,
size = 1,
colour = "black") +
scale_x_continuous(breaks = seq(0, 20, 1)) +
ylab("Frequency") +
labs(linetype = "Group")
## Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
## ℹ Please use `linewidth` instead.
## This warning is displayed once per session.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning
## was generated.
ggplot(mydata, aes(x = Mobile)) +
geom_histogram(binwidth = 1,
colour = "black",
fill = "grey80",
boundary = 0) +
scale_x_continuous(breaks = seq(0, 20, 1)) +
ylab("Frequency") +
facet_wrap(~ Gender, ncol = 1)
library(effectsize)
##
## Attaching package: 'effectsize'
## The following object is masked from 'package:psych':
##
## phi
## The following objects are masked from 'package:rstatix':
##
## cohens_d, eta_squared, omega_squared
effectsize(wilcox.test(mydata$Mobile ~ mydata$Gender,
correct = FALSE,
exact = FALSE,
alternative = "two.sided"))
## r (rank biserial) | 95% CI
## ---------------------------------
## -0.19 | [-0.40, 0.03]
library(effectsize)
interpret_rank_biserial(0.19)
## [1] "small"
## (Rules: funder2019)